/*
角色管理相关的API请求函数
*/
import request from '@/utils/request'

const api_name = '/admin/system/sysRole'

export default {

  /*
  获取角色分页列表(带搜索)
  */
  getPageList(page, limit, searchObj) {
    return request({
      url: `${api_name}/${page}/${limit}`,
      method: 'get',
      params: searchObj
    })
  },

  //角色删除
  removeById(id) {
    return request({
      url: `${api_name}/remove/${id}`,
      method: 'delete'
    })
  },

  //角色添加
  save(role) {
    return request({
      url: `${api_name}/addRole`,
      method: 'post',
      data: role
    })
  },

  //获取角色对象
  getById(id) {
    return request({
      url: `${api_name}/getRole/${id}`,
      method: 'get'
    })
  },

  //修改角色
  updateById(role) {
    return request({
      url: `${api_name}/updateRole`,
      method: 'put',
      data: role
    })
  },

  //批量删除
  batchRemove(idList) {
    return request({
      url: `${api_name}/deleteByBatch`,
      method: `delete`,
      data: idList
    })
  },

  getRoles(adminId) {
    return request({
      url: `${api_name}/toAssign/${adminId}`,
      method: 'get'
    })
  },

  assignRoles(assginRoleVo) {
    return request({
      url: `${api_name}/doAssign`,
      method: 'post',
      data: assginRoleVo
    })
  },

  //查询全部角色列表
  findAll(){
    return request({
      url: `${api_name}/findAll`,
      method: 'get'
    })
  }
}
